<?php


namespace App\Http\Controllers\Admin;


use App\Http\Controllers\Controller;
use App\Models\AdminUser;
use App\Models\Commodity;
use App\Models\CommodityOrder;
use EasyWeChat\Factory;
use Illuminate\Http\Request;

class OrderController extends Controller
{


    public function orderLits(Request $request)
    {
        $request->input();
        $data = CommodityOrder::orderBy('created_at', 'desc')->paginate(10);
        return $this->makeResponse($data, '查询成功', 200);
    }


    public function orderDetail($id)
    {
        $data = CommodityOrder::with('detail.spu')->find($id);
        return $this->makeResponse($data, '查询成功', 200);
    }

    public function login(Request $request)
    {

        $adminUswer = new AdminUser();
        $userInfo = $adminUswer->checkLogin($request->input());
        if ($userInfo['status'] == 1) {
            return $this->makeResponse($userInfo['data'], '登陆成功', 200);
        } else {
            return $this->makeResponse([], '帐号或密码错误', 500);
        }

    }

    public function daoru()
    {

        $config = config('wechat');
        $app = Factory::officialAccount($config);
        $oauth = $app->oauth;
    }

}